// components/field/field.js
Component({
	/**
	 * 组件的属性列表
	 */
	properties: {
		value: { type: String, value: '' },
		prop: { type: String, value: '' },
		icon: { type: String, value: '' },
		label: { type: String, value: '' },
		type: { type: String, value: 'text' },
		small: { type: Boolean, value: false },
		placeholder: { type: String, value: '' },
		clearable: { type: Boolean, value: false },
		showPassword: { type: Boolean, value: false },
	},

	/**
	 * 组件的初始数据
	 */
	data: { dom: null, focus: false, password: true },

	ready() {},

	/**
	 * 组件的方法列表
	 */
	methods: {
		focusFn() {
			this.setData({
				focus: true,
			})
		},
		blurFn() {
			this.setData({
				focus: false,
			})
		},
		fieldInput(e) {
			this.triggerEvent('input', e.detail.value)
		},
		clearFn() {
			this.setData({
				focus: true,
				value: '' 
			})
			this.fieldInput({ detail: { value: '' } })
		},
		changePassFn() {
			this.setData({
				password: !this.data.password,
			})
		},
	},
})
